﻿<%@ Control Language="VB" AutoEventWireup="false" CodeFile="Uc_group_user_list.ascx.vb" Inherits="Apps_Shares_Uc_group_user_list" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<%--==============================BEGIN Filter==============================--%>
<table width="60%" border="1" align="center" cellpadding="2" cellspacing="2" bordercolor="#999999">
    <tr align="center" bgcolor="#99FFFF">
        <td colspan="2" bgcolor="#FFFFFF" class="th_data">
            ค้นหาข้อมูล
        </td>
    </tr>
    <tr align="left">
        <td width="47%" bordercolor="#CCCCCC" class="td_box">
            ชื่อกลุ่มผู้ใช้งาน :
        </td>
        <td width="53%" bordercolor="#CCCCCC" class="td_box">
            <asp:TextBox ID="txtGroupName" runat="server"></asp:TextBox>
        </td>
    </tr>
    <tr align="left">
        <td width="47%" bordercolor="#CCCCCC" class="td_box">
            ประเภท :
        </td>
        <td width="53%" bordercolor="#CCCCCC" class="td_box">
            <asp:DropDownList ID="ddlCategory" runat="server" AppendDataBoundItems="True" 
                DataSourceID="ddlCategorySrc" DataTextField="group_user_type_name" 
                DataValueField="group_user_type">
                <asp:ListItem Text="ประเภท" Value="0"></asp:ListItem>
            </asp:DropDownList>
            <asp:SqlDataSource ID="ddlCategorySrc" runat="server" 
                ConnectionString="<%$ ConnectionStrings:GHBankConnectionString %>" 
                ProviderName="<%$ ConnectionStrings:GHBankConnectionString.ProviderName %>" 
                SelectCommand="Select * from group_user_type"></asp:SqlDataSource>
        </td>
    </tr>
    <tr align="left">
        <td width="47%" bordercolor="#CCCCCC" class="td_box">
            หน่วยงาน :
        </td>
        <td width="53%" bordercolor="#CCCCCC" class="td_box">
            <asp:DropDownList ID="ddlStpDepartment" runat="server" AppendDataBoundItems="True"
                DataSourceID="ddlStpDepartmentSrc" DataTextField="department_name" DataValueField="department_code">
                <asp:ListItem Text="หน่วยงาน" Value="0"></asp:ListItem>
            </asp:DropDownList>
            <asp:ObjectDataSource ID="ddlStpDepartmentSrc" runat="server" SelectMethod="GetStpDepartmentByPrivilege"
                TypeName="CodeMatrix.Business.GenericData"></asp:ObjectDataSource>
        </td>
    </tr>
    <tr align="left">
        <td width="47%" bordercolor="#CCCCCC" class="td_box">
            สถานะ :
        </td>
        <td width="53%" bordercolor="#CCCCCC" class="td_box">
            <asp:DropDownList ID="ddlStatus" runat="server">
                <asp:ListItem Text="สถานะ" Value="0"></asp:ListItem>
                <asp:ListItem Text="ใช้งาน" Value="1"></asp:ListItem>
                <asp:ListItem Text="ไม่ใช้งาน" Value="2"></asp:ListItem>
            </asp:DropDownList>
        </td>
    </tr>
    <tr align="left">
        <td width="47%" bordercolor="#CCCCCC" class="td_box">
            จำนวนวันที่หมดอายุรหัสผ่าน :
        </td>
        <td width="53%" bordercolor="#CCCCCC" class="td_box">
            <asp:TextBox ID="txtExpireQty" runat="server" Width="40px" MaxLength="3"></asp:TextBox>
        </td>
    </tr>
    <tr align="center">
        <td colspan="2" bordercolor="#CCCCCC" class="td_data_end">
            <asp:Button ID="btnFilter" Text="<%$ Resources:Resource,BTN_SEARCH %>" runat="server" />
            <asp:Button ID="btnMainMenu" Text="<%$ Resources:Resource,BTN_MAINMENU %>" runat="server" PostBackUrl="~/Apps/ViewSystem.aspx?Edit=2" />
        </td>
    </tr>
</table>
<%--==============================END Filter==============================--%>
<div style="margin:5px;display:block;width:100%">&nbsp;</div>
<%--==============================BEGIN Display==============================--%>
<span class="component_caption">
    <asp:Literal ID="ltrCountView" runat="server" Text=""></asp:Literal></span>
<asp:ListView ID="gvDisplay" runat="server" DataSourceID="srcList" DataKeyNames="group_user_code"
    EnableModelValidation="True">
    <LayoutTemplate>
        <table cellspacing="2" cellpadding="2" bordercolor="#999999" border="0" align="center" width="100%">
            <tbody>
                <tr bgcolor="#ff9999" align="center">
                    <td bgcolor="#ffffff" class="th_data">
                        <asp:Image ID="group_user_name" runat="server" Visible="false" />
                        <asp:LinkButton ID="sort2" runat="server" CommandName="Sort" CommandArgument="group_user_name">
                                ชื่อกลุ่มผู้ใช้งาน
                        </asp:LinkButton>
                    </td>
                    <td bgcolor="#ffffff" class="th_data">
                        <asp:Image ID="department_name" runat="server" Visible="false" />
                        <asp:LinkButton ID="sort3" runat="server" CommandName="Sort" CommandArgument="department_name">
                                หน่วยงาน
                        </asp:LinkButton>
                    </td>
                    <td bgcolor="#ffffff" class="th_data">
                        <asp:Image ID="group_user_password_expire" runat="server" Visible="false" />
                        <asp:LinkButton ID="sort4" runat="server" CommandName="Sort" CommandArgument="group_user_password_expire">
                               จำนวนวันที่หมดอายุ
                        </asp:LinkButton>
                    </td>
                    <td bgcolor="#ffffff" class="th_data">
                        <asp:Image ID="group_user_type_name" runat="server" Visible="false" />
                        <asp:LinkButton ID="sort5" runat="server" CommandName="Sort" CommandArgument="group_user_type_name">
                                ประเภท
                        </asp:LinkButton>
                    </td>
                    <td bgcolor="#ffffff" class="th_data">
                        <asp:Image ID="status" runat="server" Visible="false" />
                        <asp:LinkButton ID="sort6" runat="server" CommandName="Sort" CommandArgument="status">
                                สถานะ
                        </asp:LinkButton>
                    </td>
                    <td bgcolor="#ffffff" class="th_data col_delete">
                        <input id="icbHeader" type="checkbox" />
                        ลบข้อมูล
                    </td>
                </tr>
                <asp:PlaceHolder ID="itemPlaceholder" runat="server" />
                <tr bgcolor="#ff9999" align="center">
                    <td bgcolor="#ffffff" class="td_data_end" colspan="5">
                        <%-- ====================== Data Pager ======================--%>
                        <asp:DataPager ID="paging" runat="server" PagedControlID="gvDisplay" PageSize="10">
                            <Fields>
                                <asp:NextPreviousPagerField ShowFirstPageButton="true" ShowLastPageButton="false"
                                    ShowNextPageButton="false" ShowPreviousPageButton="false" FirstPageText="<<" />
                                <asp:NextPreviousPagerField ShowFirstPageButton="false" ShowLastPageButton="false"
                                    ShowNextPageButton="false" ShowPreviousPageButton="true" PreviousPageText="<" />
                                <asp:NumericPagerField />
                                <asp:NextPreviousPagerField ShowFirstPageButton="false" ShowLastPageButton="false"
                                    ShowNextPageButton="true" ShowPreviousPageButton="false" NextPageText=">" />
                                <asp:NextPreviousPagerField ShowFirstPageButton="false" ShowLastPageButton="true"
                                    ShowNextPageButton="false" ShowPreviousPageButton="false" LastPageText=">>" />
                            </Fields>
                        </asp:DataPager>
                        <%-- ====================== Data Pager ======================--%>
                    </td>
                    <td bgcolor="#ffffff" class="td_data_end col_delete">
                        <asp:Button ID="btnDelete" runat="server" Text="ลบข้อมูล" OnClick="btnDelete_Click"
                            OnClientClick="<%$Resources:Resource,SCRIPT_CONFIRM_DELETE %>" />
                    </td>
                </tr>
            </tbody>
        </table>
    </LayoutTemplate>
    <EmptyDataTemplate>
        <br />
        <span class="star">
            <center>
                ไม่พบข้อมูล</center>
        </span>
    </EmptyDataTemplate>
    <ItemTemplate>
        <tr>
            <td align="left" class="td_data" bordercolor="#CCCCCC">
                <a href="<%# "group_user_fv.aspx?Edit=" & Eval("group_user_code") & CodeMatrix.Business.GenericData.GetViewMode() %>">
                    <%# Eval("group_user_name")%>
                </a>
            </td>
            <td align="left" class="td_data" bordercolor="#CCCCCC">
                <%#String.Format("{0}", CodeMatrix.Business.UserContext.PadLeft(Eval("master_department_level") - 1, "&nbsp;&nbsp;&nbsp;&nbsp;"))%><%#Eval("department_name")%>
            </td>
            <td align="left" class="td_data" bordercolor="#CCCCCC">
                <%# Eval("group_user_password_expire")%>
            </td>
            <td align="left" class="td_data" bordercolor="#CCCCCC">
                <%# Eval("group_user_type_name")%>
            </td>
            <td align="center" class="td_data f_status" bordercolor="#CCCCCC">
                <%# Eval("status")%>
            </td>
            <td align="center" class="td_data col_delete" bordercolor="#CCCCCC">
                <asp:CheckBox ID="icbItem" runat="server" />
            </td>
        </tr>
    </ItemTemplate>
</asp:ListView>
<asp:ObjectDataSource ID="srcList" runat="server" DeleteMethod="Delete" SelectMethod="GetData"
    TypeName="GroupUser">
    <DeleteParameters>
        <asp:Parameter DefaultValue="group_user" Name="tbl" Type="String" />
        <asp:Parameter DefaultValue="group_user_code" Name="pid" Type="String" />
        <asp:Parameter DefaultValue="" Name="cid" Type="String" />
    </DeleteParameters>
    <SelectParameters>
        <asp:ControlParameter ControlID="txtGroupName" ConvertEmptyStringToNull="False" Name="group_user_name"
            PropertyName="Text" />
        <asp:ControlParameter ControlID="ddlCategory" Name="group_user_type" PropertyName="SelectedValue" />
        <asp:ControlParameter ControlID="ddlStatus" Name="group_user_status" PropertyName="SelectedValue" />
        <asp:ControlParameter ControlID="txtExpireQty" Name="group_user_password_expire"
            PropertyName="Text" ConvertEmptyStringToNull="false" />
        <asp:ControlParameter ControlID="ddlStpDepartment" Name="department_code" PropertyName="SelectedValue" />
        <asp:SessionParameter Name="ctx_group_user_type" SessionField="group_user_type" />
        <asp:SessionParameter Name="ctx_department_code" SessionField="department_code" />
    </SelectParameters>
</asp:ObjectDataSource>
<%-- ====================== Data Pager ======================--%>

<script type="text/javascript">
    <%--==============================To mark all check box==============================--%>
    matchTableCheckBox("icbHeader", "icbItem");
    hideDeleteColumn();
    hilightInactive();
</script>

<script type="text/javascript">
    $(document).ready(function() {
        $("#" + "<%=txtExpireQty.ClientID%>").keypress(function(e) {
            //if the letter is not digit then display error and don't type anything
            if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
                return false;
            }
        });
    });
</script>

